package com.example.waternetwork.api.exception;

import com.example.waternetwork.api.model.R;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.client.HttpClientErrorException;

@RestControllerAdvice
public class GlobalExceptionHandler {

    private static final Logger logger = LoggerFactory.getLogger(GlobalExceptionHandler.class);
    @ExceptionHandler(Exception.class)
    public R<String> handleGenericException(Exception ex) {
        logger.error("【系统异常】", ex);
        return R.fail(500, "系统内部错误，请联系管理员");
    }
}
